package com.tanhua.dubbo.server.service.impl;

import com.tanhua.dubbo.server.enums.IdType;
import com.tanhua.dubbo.server.service.IdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class IdServiceImpl implements IdService {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    public Long createId(IdType idType) {
        String key = "TANHUA_ID_" + idType.toString();
        return this.redisTemplate.opsForValue().increment(key);
    }
}
